package org.NooLab.glue.components.pkg;

import java.io.Serializable;
import java.util.Vector;

import org.NooLab.glue.msgframe.XRegistration;
import org.NooLab.glue.subscription.context.Context;
import org.NooLab.glue.transaction.Transaction;



/**
 * 
 * this class actually acts as a container for any user-based object, which 
 * will be transported as "dataObj"
 * 
 * note that this object need to be serializable !
 * 
 */
public class TaskPackage implements Serializable, Cloneable {

	transient private static final long serialVersionUID = -6310500763383951297L;

	// =================================

	// object references ..............

	transient XRegistration xRegistration ;
	
	private boolean transmitResourceAsReference=false;
	
	// main variables / properties ....

	private String contentType; // general description of the content
	
	
	private String dataObjIdentifier;
	
	private Object dataObj ;
 	
	Context context ;
	
	// describes a property of provided data
	private String typeOfProceedings = "" ; // "task", "travel" (from the perspective of the data itself
									// meaning that sth is calculated or assimilated
	private Object eligibilityForReceptors;
	
	// ** this can be used to provide information about which class should be used to cast the dataObj */
	// Class<?> decastingClass;
	
	/** a simple data string for textual data */
	private String dataString ;
	
	/** an indicator for handling, mostly simply whether positive or negative;
	 *  not related to the state of transaction, is used just internal of instances  */
	private int stateFlag = 0;
	
	// thats just for testing
	private Vector<Integer> nums = new Vector<Integer>(); 
	
	// constants ......................
	
 
	// volatile variables .............
 	transient long transactionID = -1;
	transient Transaction transactionMirror;
	
	// helper objects .................
 
	
	// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
	/*
	public TaskPackage( XRegistration xreg){
		xRegistration = xreg;
	}
	*/
	public TaskPackage( ){
		
	}
	// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
	
	
	 
	// ------------------------------------------------------------------------

 
	public XRegistration getxRegistration() {
		return xRegistration;
	}

	public void setxRegistration(XRegistration xRegistration) {
		this.xRegistration = xRegistration;
	}

	public void setTransmitResourceAsReference(boolean b) {
		 
		transmitResourceAsReference = b;
	}


	public boolean isTransmitResourceAsReference() {
		return transmitResourceAsReference;
	}

	public boolean getTransmitResourceAsReference() {
		return transmitResourceAsReference;
	}
	
	
	// object is "DataContainer{}"
	public void setData( Object obj , String identifier ) {
		dataObj = obj;
		dataObjIdentifier = identifier ;
	}


	
	public String getContentType() {
		return contentType;
	}



	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	
	// setTypeOfProceedings
	
	
	public Object getDataObj() {
		return dataObj;
	}

	public void setDataObj(Object dataObj) {
		this.dataObj = dataObj;
	}

 

	public Context getContext() {
		return context;
	}



	public void setContext(Context context) {
		this.context = context;
	}



	public Object getEligibilityForReceptors() {
		return eligibilityForReceptors;
	}

	public void setEligibilityForReceptors(Object eligibilityForReceptors) {
		this.eligibilityForReceptors = eligibilityForReceptors;
	}

	public Vector<Integer> getNums() {
		return nums;
	}

	public void setNums(Vector<Integer> nums) {
		this.nums = nums;
	}

	public String getDataString() {
		return dataString;
	}

	public void setDataString(String dataString) {
		this.dataString = dataString;
	}

	public String getDataObjIdentifier() {
		return dataObjIdentifier;
	}

	public void setDataObjIdentifier(String dataObjIdentifier) {
		this.dataObjIdentifier = dataObjIdentifier;
	}

	public String getTypeOfProceedings() {
		return typeOfProceedings;
	}

	public void setTypeOfProceedings(String typeOfProceedings) {
		this.typeOfProceedings = typeOfProceedings;
	}

	public int getStateFlag() {
		return stateFlag;
	}

	public void setStateFlag(int stateFlag) {
		this.stateFlag = stateFlag;
	}

	public long getTransactionID() {
		return transactionID;
	}

	public void setTransactionID(long transactionID) {
		this.transactionID = transactionID;
	}

	public Transaction getTransactionMirror() {
		return transactionMirror;
	}

	public void setTransactionMirror(Transaction transactionMirror) {
		this.transactionMirror = transactionMirror;
	}

	
	public TaskPackage clone() { //  throws CloneNotSupportedException
		
		TaskPackage tp=null;
		
		try {
			tp = (TaskPackage)super.clone();
		
			tp.dataObj = dataObj ;
			tp.context = context ;
			tp.eligibilityForReceptors = eligibilityForReceptors;
			tp.transactionMirror = transactionMirror;
			
			if (xRegistration!=null){
				tp.xRegistration = xRegistration;
			}
				
		} catch (CloneNotSupportedException cnse) {
			// throw new CloneNotSupportedException();
			cnse.printStackTrace();
		}
		return tp;
	}
	
}
